<template>
	<div>

		<el-dialog title="生产订单详情" width="80%" @open="open" class="icon-dialog" :visible.sync="show" :before-close="closeForm" append-to-body>
      <div>
        <el-button type="primary" size="small" icon="el-icon-check"  @click="saveOrder()">&nbsp;保&nbsp;存&nbsp;</el-button>
        <el-button type="primary" size="small" icon="el-icon-s-promotion" @click="doAudit" v-if="header.status === 'save'">&nbsp;审&nbsp;核&nbsp;</el-button>
      </div>
      <el-form>
        <el-row>
          <el-col :span="6">
            <el-form-item :label="$t('field.Proorder_billNo')">{{header.billNo}} </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('field.Proorder_type')">{{header.type}} </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="$t('field.Proorder_status')">
              <el-tag :type="header.status === 'save'? 'info': (header.status === 'audit'? 'success': 'danger')">{{ header.status === 'save'? '保存': (header.status === 'audit'? '审核': '关闭') }}</el-tag>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item :label="$t('field.Proorder_createTime')">{{header.createTime}} </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('field.Proorder_workShop')">{{header.workShop}} </el-form-item>
          </el-col>

        </el-row>
      </el-form>
      <el-table :data="dataList" height="calc(80vh - 250px)">
        <el-table-column label="No." width="60" align="right" type="index"></el-table-column>
        <el-table-column label="物料编码" width="120" prop="materialNo"></el-table-column>
        <el-table-column label="物料名称" width="120" prop="materialName"></el-table-column>
        <el-table-column label="物料规格" width="120" prop="specification"></el-table-column>
        <el-table-column label="单位" width="60" prop="unit"></el-table-column>
        <el-table-column label="指定批号" width="80" prop="batchNo"></el-table-column>
        <el-table-column label="数量" width="60" prop="count"></el-table-column>
        <el-table-column label="几锅完成" width="60" prop="batch"></el-table-column>
        <el-table-column label="指定生产日期" width="150" prop="specifyDate"></el-table-column>
      </el-table>

      <el-table :data="userList" height="calc(80vh - 250px)">
        <el-table-column label="No." width="60" align="right" type="index"></el-table-column>
        <el-table-column label="员工姓名" width="120" prop="userName"></el-table-column>
        <el-table-column label="员工工作类型" width="120" prop="workShop"></el-table-column>
        <el-table-column label="是否冷库" width="120" prop="isColdStock"></el-table-column>
        <el-table-column label="计件比例" width="120" prop="userProportion"></el-table-column>
        <el-table-column label="实际车间" width="120" prop="Fwork"></el-table-column>
        <el-table-column label="开工时间" width="120" prop="startDate"></el-table-column>
        <el-table-column label="结束时间" width="120" prop="endDate"></el-table-column>
        <el-table-column label="工时(分钟)" width="120" prop="workTime">
          <template slot-scope="scope">
            <el-input   size="small" v-model="scope.row.workTime"  style="width: 80px;" :min="0"    />
          </template>
        </el-table-column>
      </el-table>
		</el-dialog>
	</div>
</template>
<script>
import { detail,updateWorkTime  } from '@/api/app/proorder'
export default {
	name:'proorderdetail',
	props: {
		show: {
			type: Boolean,
			default: true
		},
		size: {
			type: String,
			default: 'mini'
		},
		info: {
			type: Object,
		},
	},
	data() {
		return {
			header:{},
      dataList:[],
      userList:[]
		}
	},
	watch:{
		show(val){
			if(val){
			}
		}
	},
	methods: {
    /**
     * 保存订单信息(修改工时)
     */
    saveOrder(){
      updateWorkTime({datalist : this.userList}).then(res => {
        console.log(res)
      })
    },
		open(){
			detail(this.info).then(res => {
				this.header = res.data.header
        this.dataList = res.data.dataList
        this.userList = res.data.userList
			})
		},
		closeForm(){
			this.$emit('update:show', false)
		}
	}
}
</script>
<style  lang="scss">
@import '@/assets/scss/common.scss';
</style>
